using System;
using System.Collections.Generic;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Web;
using System.Collections.Specialized;
using DapperDB.Dal;

namespace DapperDB.Entities
{

	public partial class Task_LogDap : BaseDap
	{
		public Task_LogDap()
		{
		}

		public Task_LogDap(IDbConnection connection)
		{
			Connection = connection;
		}

		public Task_LogDap(IDbTransaction transaction)
		{
			Transaction = transaction;
			Connection = transaction.Connection;
		}

		public Task_LogDap(BaseDap dapProvider)
		{
			Transaction = dapProvider.Transaction;
			Connection = dapProvider.Connection;
		}

		public List<Task_Log> GetTop(int count)
		{
			return Query<Task_Log>(string.Format("SELECT TOP {0} * FROM {1}", count, SqlTableName)).ToList();
		} 

		public Task_Log GetByID(Int32 ID)
		{
			return Query<Task_Log>(SqlSelectCommand + " WHERE StoreId=@StoreId", new { ID = ID }).FirstOrDefault();
		}

		public void Insert(Task_Log model)
		{ 
			Execute(SqlInsertCommand, model);
		}
		
	 

		public void Insert(IEnumerable<Task_Log> models)
		{ 
         Execute(SqlInsertCommand, models);
		}

		public void Delete(Int32 ID)
		{ 
			Execute(SqlDeleteCommand, new { ID = ID });
		}

		public void Update(Task_Log model)
		{ 
			Execute(SqlUpdateCommand, model);
		}
	 
		public void DeleteExt(string ID)
		{
			Int32 key = Convert.ToInt32(ID);
			Execute(SqlDeleteCommand, new { ID = key }); 
		}
		
		public void DeleteExtBat(string pkNameArr)
		{
			Execute(SqlDeleteCommandBat + "  where ID in ("+pkNameArr+")" ); 

		}

		public Task_Log GetByKey(string ID)
		{
			return Query<Task_Log>(SqlSelectCommand + " WHERE ID=@ID", new { ID = ID }).FirstOrDefault();

		}
		
		public void Update(IEnumerable<Task_Log> models)
		{
			IEnumerator iEnumerator = models.GetEnumerator();
			StringBuilder sb = new StringBuilder();
			while (iEnumerator.MoveNext())
			{
				Task_Log cur = (Task_Log)iEnumerator.Current;
				string keyid = cur.ID;
				sb.Append(keyid);
			} 
			Execute(SqlUpdateCommand, models);
		}

		public const string SqlTableName = "Task_Log";
		public const string SqlSelectCommand = "SELECT * FROM " + SqlTableName;
		public const string SqlInsertCommand = "INSERT INTO " + SqlTableName + " ( ID ,Title ,LogText ,CreateTime  ) VALUES ( @ID ,@Title ,@LogText ,@CreateTime  ) ";
		public const string SqlUpdateCommand = "UPDATE " + SqlTableName + " SET ID= @ID ,Title= @Title ,LogText= @LogText ,CreateTime= @CreateTime  WHERE ID=@ID";
		public const string SqlDeleteCommand = "DELETE FROM " + SqlTableName + " WHERE ID=@ID";
		public const string SqlDeleteCommandBat = "DELETE FROM " + SqlTableName;

	
	}

}
